package dao;

import java.util.ArrayList;

import org.hibernate.Session;
import org.hibernate.Transaction;

import entity.City;

public class CityDao {
	
	@SuppressWarnings("unchecked")
	public ArrayList<City> getAllCity(){
		
		ArrayList<City> cityList=null;
		Session session=null;
		Transaction tx=null;
		
		try {
			session=HibernateSessionFactory.getSession();
			tx=session.beginTransaction();
			
			cityList=(ArrayList<City>)session.createQuery("from City")
						.list();
			tx.commit();
		} catch (Exception e) {
			tx.rollback();
			e.printStackTrace();
		}finally{
			
			HibernateSessionFactory.closeSession();
			
		}
		return cityList;
	}
	

}
